//         https://ac.nowcoder.com/acm/problem/50041






#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;


const int N = 110;

const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, 1, 0, -1 };

int n, m, sx, sy;
int dis[N][N];
char str[N][N];

void bfs()
{
    queue<pair<int, int> > Q;
    memset(dis, 0x3f3f3f3f, sizeof(dis));
    dis[sx][sy] = 0;
    Q.push(make_pair(sx, sy));
    while (!Q.empty()) {
        int x = Q.front().first;
        int y = Q.front().second;
        Q.pop();
        for (int i = 0; i < 4; i++)
        {
            int xx = x + dx[i];
            int yy = y + dy[i];
            if (0 <= xx && xx < n && 0 <= yy && yy < m && str[xx][yy] != '*' && dis[xx][yy] > 1e8)
            {
                dis[xx][yy] = dis[x][y] + 1;
                if (str[xx][yy] != 'e')
                    Q.push(make_pair(xx, yy));
            }
        }
    }
    int a1 = 0, a2 = 0x3f3f3f3f;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (str[i][j] == 'e' && dis[i][j] < 1e8)
            {
                a1++;
                a2 = min(a2, dis[i][j]);
            }
    if (a1 == 0) puts("-1");
    else printf("%d %d\n", a1, a2);
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", str[i]);
        for (int j = 0; j < m; j++)
            if (str[i][j] == 'k')
                sx = i, sy = j;
    }
    bfs();
    return 0;
}
